home *** CD-ROM | disk | FTP | other *** search
- /*
- * Offscreen.c
- */
-
-
- #include <QDOffscreen.h>
- #include "Offscreen.h"
-
-
- WindowOffscreen *DrawOffscreen(WindowPtr theWindow)
-
- { WindowOffscreen *theOffscreen;
- GWorldPtr theWorld;
- short depth;
- Rect globalRect;
-
- if ((theOffscreen = (WindowOffscreen *) NewPtr(sizeof(WindowOffscreen))) == 0L)
- return(0L);
-
- SetPort(theWindow);
- GetGWorld(&theOffscreen->windowPort, &theOffscreen->windowDevice);
-
- globalRect = theWindow->portRect;
- LocalToGlobal((Point *) &globalRect.top);
- LocalToGlobal((Point *) &globalRect.bottom);
-
- if (NewGWorld(&theWorld, 0, &globalRect, 0L, 0L, 0) == noErr) {
-
- SetGWorld(theWorld, 0L);
- if (! LockPixels(theWorld->portPixMap)) {
- DisposeGWorld(theWorld);
- DisposePtr(theOffscreen);
- return(0L);
- }
-
- CopyBits(&theWindow->portBits,
- &((GrafPtr) theWorld)->portBits,
- &theWindow->portRect,
- &theWorld->portRect,
- srcCopy, 0L);
-
- theOffscreen->offscreenWorld = theWorld;
- return(theOffscreen);
-
- } else {
-
- DisposePtr(theOffscreen);
- return(0L);
-
- }
- }
-
-
-
- void DrawOnscreen(WindowOffscreen *theOffscreen)
-
- {
- if (theOffscreen) {
- SetGWorld(theOffscreen->windowPort, theOffscreen->windowDevice);
- CopyBits(&((GrafPtr) theOffscreen->offscreenWorld)->portBits,
- &(theOffscreen->windowPort)->portPixMap,
- &theOffscreen->offscreenWorld->portRect,
- &theOffscreen->windowPort->portRect,
- srcCopy, 0L);
- UnlockPixels(theOffscreen->offscreenWorld->portPixMap);
- DisposeGWorld(theOffscreen->offscreenWorld);
- DisposePtr((Ptr) theOffscreen);
- }
- }
-